package com.share.beta.config.proxyclass;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class UseImplExample {
    @Autowired
    private ImplServiceBeanDefinitionRegistry implRegistry;

    @Autowired
    private ApplicationContext applicationContext;

    /**
     * 使用案例---直接触发这个方法方法即可
     *
     * @param args
     */
    public void toRegister(ApplicationArguments args) {
        String implClassPath = "com.share.beta.proxystandard.impl.StandardServiceImpl";
        implRegistry.registerBean(implClassPath);
    }

    /**
     * 使用案例---直接触发这个方法方法即可
     *
     * @param args
     */
    public void callBean(ApplicationArguments args) {
        Object implService = applicationContext.getBean("standardServiceImpl"); //注意这里的大写
        log.info("---" + implService);
    }
}
